<template>
  <div class="app-container">
    <el-form :model="form" ref="refForm" :rules="rules">
      <!--<el-row :gutter="20">-->
        <!--<el-col :span="8">-->
          <!--<el-form-item label="同IP重复注册（秒)：" prop="regTime">-->
            <!--<el-input v-model="form.regTime" placeholder="秒"></el-input>-->
            <!--<el-tip>同一IP在多少时间内，最多能注册多少账号。0或空标识不限制。</el-tip>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
        <!--<el-col :span="8">-->
          <!--<el-form-item label="注册账号数量：" prop="regNum">-->
            <!--<el-input v-model="form.regNum" placeholder=""></el-input>-->
          <!--</el-form-item>-->
        <!--</el-col>-->

      <!--</el-row>-->
      <el-row :gutter="20">
        <el-col :span="8">
          <el-form-item label="登录超时时间:" prop="loginTime">
            <el-input v-model="form.loginTime" placeholder="分"></el-input>
            <el-tip>超出设定时间，将自动退出登录。0或留空表示不限制。</el-tip>
          </el-form-item>
        </el-col>
      </el-row>
      <el-row>
        <el-button type="primary" :loading="loading" @click="doSave({action: 'saveForm', form: 'refForm'})">保存
        </el-button>
        <el-button @click="resetForm('refForm')">复原</el-button>
      </el-row>
    </el-form>
  </div>
</template>

<script>
  import {form, factory} from '@/build';
  import {systemConfigureGetApi, systemConfigureSaveApi} from '@/services/api/system';

  /**
   * 标准表单开发流程
   * 1. 完成ui
   * 2. 绑定数据
   * 3. 写验证规则
   * 4. 绑定api
   */
  export default {
    name: "sys-setting",
    mixins: [form],

    data() {
      return {
        form: {
          regTime: undefined,
          regNum: undefined,
          loginTime: undefined
        },
        rules: {
          regTime: [
            {validator: factory.getValidator('nonNegativeInteger'), trigger: 'change'}
          ],
          regNum: [
            {validator: factory.getValidator('nonNegativeInteger'), trigger: 'change'}
          ],
          loginTime: [
            {validator: factory.getValidator('nonNegativeInteger'), trigger: 'change'}
          ],
        }
      }
    },

    mounted() {
      this.bindGet(systemConfigureGetApi, 'form', {
        format: data => {

          return data || {}
        }
      });
      this.bindSave(systemConfigureSaveApi, 'saveForm', 'form');

      this.getAll();
    },
  }
</script>

<style scoped>

</style>
